#include <string>
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;



int main(int argc, char const *argv[])
{
  string s{"BA"};

  // AB BA
  do {
    cout << s;
  } while (prev_permutation(s.begin(), s.end()));

  // next_permutation 要求 s 从小到大排序的

  while (false) {
    // ...
    cout << "1111" << endl;
  }

  do {
    cout << "2222" << endl;
  } while (false);

  return 0;
}
